import 'package:flutter/material.dart';
import 'package:flutter_app/cinema/CinemaList.dart';
import 'package:flutter_app/detail/Detail.dart';
import 'package:flutter_app/home/HomeBody.dart';
import 'package:flutter_app/move/MovieList.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //当然底部导航也可以不使用DefaultTabController，然后直接new Controller动态自定义，不过比较麻烦
    //DefaultTabController必须有，否则底部栏直接使用没法和页面建立关联关系
    return DefaultTabController(
        //控制器控制页面切换的数量，和底部导航数量要一致
        length: 3,
        child: Scaffold(
            appBar: AppBar(
              title: Text("Techsel电影"),
              centerTitle: true, //居中
              actions: <Widget>[
                IconButton(icon: Icon(Icons.search), onPressed: () {})
              ],
            ),
            //侧边栏
            drawer: Drawer(
              child: ListView(
                //去掉顶部的padding
                padding: EdgeInsets.all(0),
                children: <Widget>[
                  UserAccountsDrawerHeader(
                    accountName: Text('曾强'),
                    accountEmail: Text("1234567@qq.com"),
                    //头像区域
                    currentAccountPicture: CircleAvatar(
                      backgroundColor: Colors.white,
                      backgroundImage: NetworkImage(
                          "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=1006629194,1322383236&fm=26&gp=0.jpg"),
                    ),
                    //装饰器
                    decoration: BoxDecoration(
                        image: DecorationImage(
                            fit: BoxFit.cover, //对图片进行拉伸，cover自适应会被裁切不变形
                            image: NetworkImage(
                                "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1600407036041&di=fefc6a19c4ac4cb9fe43b5166af27144&imgtype=0&src=http%3A%2F%2Fwww.flybridal.com%2Fhuangse%2FaHR0cDovL3BpYzczLm5pcGljLmNvbS9maWxlLzIwMTUwNzIxLzMwODgyODZfMTUxOTI3MTk4MDAwXzIuanBn.jpg"))),
                  ),
                  ListTile(
                    title: Text('工作城市'),
                    trailing: Icon(Icons.send),
                  ),
                  // Color.fromRGBO(r, g, b, opacity)  可以自定义颜色
                  Divider(color: Colors.black38),
                  ListTile(
                    title: Text('兴趣爱好'),
                    trailing: Icon(Icons.feedback),
                  ),
                  Divider(color: Colors.black38), //分割线
                  ListTile(
                    title: Text('我的设置'),
                    trailing: Icon(Icons.settings),
                  ),
                ],
              ),
            ),

            //页面需要传递tabbarview实现联动
            body: TabBarView(
              children: <Widget>[
                HomeBody(),
                MovieList(),
                // Detail(),
                CinemaList()
              ],
            ),

            //底部导航
            bottomNavigationBar: Container(
              height: 50,
              decoration: BoxDecoration(color: Colors.black),
              child: TabBar(
                  labelStyle: TextStyle(
                    height: 0, //字符高度
                    fontSize: 11,
                  ),
                  tabs: <Widget>[
                    Tab(
                      text: '首页',
                      icon: Icon(Icons.home),
                    ),
                    Tab(
                      text: '正在热映',
                      icon: Icon(Icons.movie_creation),
                    ),
                    Tab(
                      text: '影院信息',
                      icon: Icon(Icons.movie_filter),
                    ),
                  ]),
            )));
  }
}
